<template>
  <div class="my">
    <div class="my-header">
      <img src="https://api-haoke-web.itheima.net/img/profile/bg.png" alt />
      <div class="my-login">
        <div class="header-img">
          <img src="https://api-haoke-web.itheima.net/img/profile/avatar.png" alt />
        </div>
        <div class="header-login" v-if="token">
          <p>{{auth}}</p>
          <p>
            <van-button type="primary" @click="exit">退出</van-button>
          </p>
          <p>编辑个人资料</p>
        </div>
        <div class="header-login" v-else>
          <p>{{auth}}</p>
          <p>
            <van-button type="primary" @click="()=>{this.$router.push('/login')}">去登录</van-button>
          </p>
        </div>
      </div>
    </div>
    <div class="my-main">
      <ul>
        <li>
          <van-icon name="wap-home-o" />我的出租
        </li>
        <li>
          <van-icon name="underway-o" /> 
          <router-link to="/history">看房记录</router-link>
        </li>
        <li>
          <router-link to="/publish">
            <van-icon name="ecard-pay" />成为房主
          </router-link>
        </li>
        <li>
          <router-link to="/personal">
            <van-icon name="contact" />个人资料
          </router-link>
        </li>
        <li>
          <van-icon name="service-o" />联系我们
        </li>
      </ul>
      <!-- <div class="my-three">
        <ul>
          <li>
            <van-icon name="wap-home-o" />我的出租
          </li>
          <li>
            <van-icon name="underway-o" />看房记录
          </li>
          <li>
            <van-icon name="coupon-o" />成为房主
          </li>
        </ul>
      </div>-->
      <!-- <div class="my-two">
        <ul>
          <li>
            <van-icon name="contact" />个人资料
          </li>
          <li>
            <van-icon name="service-o" />联系我们
          </li>
          <li></li>
        </ul>
      </div>-->
      <!-- <van-grid :column-num="3">
        <van-grid-item icon="wap-home-o" text="我的出租" />
        <van-grid-item icon="underway-o" text="看房记录" />
        <router-link>
          <van-grid-item icon="coupon-o" text="成为房主" />
        </router-link>
        <van-grid-item icon="contact" text="个人资料" />
        <van-grid-item icon="service-o" text="联系我们" />
      </van-grid>-->
    </div>
    <div class="my-footer">
      <img src="https://api-haoke-web.itheima.net/img/profile/join.png" alt />
    </div>
  </div>
</template>

<script>
import { Dialog } from "vant";
export default {
  data() {
    return {
      token: "",
      auth: "灵儿",
      show: false
    };
  },

  methods: {
    //弹框提示
    exit(e) {
      Dialog.confirm({
        title: "提示",
        message: "是否确定退出？"
      })
        .then(() => {
          // on confirm
          //清除token
          this.token = localStorage.removeItem("token");
        })
        .catch(() => {
          // on cancel
        });
    }
  },
  created() {
    //取token
    this.token = localStorage.getItem("token");
  }
};
</script>

<style>
.my {
  width: 100%;
  height: 100%;
  background: #ffffff;
}
.my-header {
  width: 100%;
  height: 300px;
  position: relative;
}
.my-header img {
  width: 100%;
  height: 200px;
}
.header-img {
  width: 70px;
  height: 70px;
  background: #ffffff;
  box-shadow: 0 2px 5px rgb(219, 219, 219);
  border-radius: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -30px;
}
.header-img img {
  width: 60px;
  height: 60px;
}
.my-login {
  width: 85%;
  height: 150px;
  background: #ffffff;
  box-shadow: 0 2px 5px rgb(219, 219, 219);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 140px;
}
.header-login {
  text-align: center;
  margin-top: 50px;
}
.header-login p {
  padding-top: 10px;
}
.header-login p {
  font-size: 0.14rem;
}
.header-login p button {
  border: none;
  width: 72px;
  height: 30px;
  border-radius: 10px;
}
.my-main {
  height: 195px;
}
.my-main ul li i {
  display: block;
  justify-content: space-between;
  flex-direction: column;
  align-items: center;
  font-size: 25px;
  margin-bottom: 8px;
}

.my-main ul {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  text-align: center;
  padding: 15px 20px;
}
.my-main ul li {
  height: 95px;
  width: calc(100% / 3);
  font-size: 0.15rem;
}
.my-main ul li a {
  display: flex;
  justify-content: space-between;
  flex-direction: column;
  align-items: center;
  font-size: 0.17rem;
  color: #000;
}
.van-grid .van-hairline--top {
  border: none;
}
.my-footer img {
  width: 100%;
  height: 84.88px;
  padding: 0 20px;
}
</style>